Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support --data-raw #18

Merged
merged 2 commits into from
Oct 13, 2022
Merged

Support --data-raw #18

merged 2 commits into from
Oct 13, 2022

Conversation

jasonmccreary
Copy link
Collaborator

@jasonmccreary jasonmccreary commented Oct 13, 2022

The --data-raw option takes some interpretation. The curl docs do not state that it is mutually exclusive from --data. From a quick tests, it seems curl merges the data when called with both --data and --data-raw.

With that said, the common use case for --data-raw seems to be independent. When passed alone, this is the exact data to send in the request payload.

This PR adds support for --data-raw to the specification above - parsing it as form data when mixed with --data or sending it as the raw body when used independently.

@jasonmccreary jasonmccreary merged commit 20bab4d into main Oct 13, 2022
@jasonmccreary jasonmccreary deleted the raw-data branch October 13, 2022 15:10
Copy link

@jonnywilliamson jonnywilliamson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just looking at the output for "with-raw-data".

Doesn't the withBody method require 2 parameters?

// Illuminate/Http/Client/PendingRequest.php
    /**
     * Attach a raw body to the request.
     *
     * @param  string  $content
     * @param  string  $contentType
     * @return $this
     */
    public function withBody($content, $contentType)
    {
        $this->bodyFormat('body');

        $this->pendingBody = $content;

        $this->contentType($contentType);

        return $this;
    }

@jasonmccreary
Copy link
Collaborator Author

I thought it was optional based on the content type of the request. However, looks like it's not. I'll need to revisit this as I use withBody in two spots.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants